package com.aaa.day05;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2024/11/15 15:16
 * @description：
 * @modified By：
 * @version:
 */
public class Person1  {
    int  id;
    String name;

    int age;

    public Person1() {
    }

    public Person1(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public Person1(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public static void main(String[] args) {
        //定义了一个长度为3的对象数组，只能存放人类对象
        Person1[] persons=new Person1[4];
        Person1 p1= new Person1(10100,"张三",19);
        Person1 p2= new Person1(10010,"李四",30);
        Person1 p3= new Person1(10050,"王五",45);
        Person1 p4= new Person1(10020,"赵六",39);
        persons[0]=p1;
        persons[1]=p2;
        persons[2]=p3;
        persons[3]=p4;
        for (int i = 0; i < persons.length; i++) {
            System.out.println(persons[i].id+"姓名："+persons[i].name+"年龄"+persons[i].age);
        }
        System.out.println("排序之后：=========");
        /*for (int i = 1; i < persons.length  ; i++) {
            for (int j = 0; j < persons.length-i; j++) {
                if(persons[j].id>persons[j+1].id){
                    //定义一个person类型临时变量
                    Person temp=null;
                    temp=persons[j];
                    persons[j]=persons[j+1];
                    persons[j+1]=temp;
                }
            }

        }*/
        Arrays.sort(persons, new MyComparator());
        for (int i = 0; i < persons.length; i++) {
            System.out.println(persons[i].id+"姓名："+persons[i].name+"年龄"+persons[i].age);
        }


        int [] aaa=new int[4];
        Arrays.fill(aaa,3);
        for (int i = 0; i < aaa.length; i++) {
            System.out.println(aaa[i]);
        }

    }



}
